package com.example.controller;

import com.example.pojo.Teach;
import com.example.service.TeachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/teach")
public class TeachController {
    @Autowired
    private TeachService teachService;
    @GetMapping("/getByPid")
    List<Teach> selectTeachByPid(int pid){
        return teachService.selectTeachByPid(pid);
    }
    @GetMapping("/getByUid")
    List<Teach> selectTeachByUid(int uid){
        return teachService.selectTeachByUid(uid);
    }
    @GetMapping("/getAll")
    List<Teach> selectAllTeach(){
        return teachService.selectAllTeach();
    }
    @GetMapping("/insert")
    int insertTeach(int pid,int uid){
        return teachService.insertTeach(pid, uid);
    }
    @PostMapping("deleteByUid")
    int deleteTeachByUid(int uid){
        return teachService.deleteTeachByUid(uid);
    }
    @PostMapping("/deleteByPid")
    int deleteTeachByPid(int pid){
        return teachService.deleteTeachByPid(pid);
    }
    @PostMapping("/update")
    int updateTeach(int pid,int uid, String time){
        return teachService.updateTeach( pid, uid, time);
    }


}
